package com.example.flutterandroid;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.Toast;

import io.flutter.embedding.android.FlutterActivity;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button button = (Button) findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(MainActivity.this, "aaaaa", Toast.LENGTH_SHORT).show();

                //方式1
                startActivity(
                        FlutterActivity.createDefaultIntent(MainActivity.this));
//
//                //方式2
//                startActivity(FlutterActivity
//                        .withNewEngine()
//                        .initialRoute("/")
//                        .build(MainActivity.this));
//                //方式3
                startActivity(
                        FlutterActivity
                        .withCachedEngine("my_engine_id")
                        .build(MainActivity.this));

            }
        });
    }
}